package com.qiangesoft.blog.controller.manage;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiangesoft.blog.common.annotation.OperationLog;
import com.qiangesoft.blog.common.constants.FieldConstants;
import com.qiangesoft.blog.core.entity.BlogAuthConfig;
import com.qiangesoft.blog.core.service.IBlogAuthConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 作者配置管理 前端控制器
 * </p>
 *
 * @author qiange
 */
@RestController
@RequestMapping("/blog/authConfig")
@Api(tags = "作者配置管理")
@RequiredArgsConstructor
public class BlogAuthConfigController {

    private final IBlogAuthConfigService authConfigService;

    @PutMapping
    @ApiOperation(value = "修改作者配置")
    @OperationLog(value = "修改作者配置")
    public void update(@RequestBody BlogAuthConfig authConfig) {
        authConfigService.updateById(authConfig);
    }

    @GetMapping
    @ApiOperation(value = "获取作者配置")
    public BlogAuthConfig getConfig() {
        return authConfigService.getOne(new LambdaQueryWrapper<BlogAuthConfig>().last(FieldConstants.LIMIT_ONE));
    }
}

